package com.hsav.kcxb.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hsav.kcxb.R;
import com.hsav.kcxb.activity.RecordActivity;
import com.hsav.kcxb.activity.UnisonListActivity;
import com.zhy.autolayout.utils.AutoUtils;

/**
 * Created by zhao on 2017/2/11.
 */

public class SongListAdapter extends BaseAdapter {

    private final Context mContext;
    private final LayoutInflater mInflater;

    public SongListAdapter(Context context) {
        this.mContext = context;
        this.mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return 8;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.item_singlist_view, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.headImg = (ImageView)convertView.findViewById(R.id.img_song_head);
            viewHolder.songTitleTx = (TextView)convertView.findViewById(R.id.tx_song_title);
            viewHolder.shareUserTx = (TextView)convertView.findViewById(R.id.tx_song_share);
            viewHolder.singerTx = (TextView)convertView.findViewById(R.id.tx_song_singer);
            viewHolder.singShowTx = (TextView)convertView.findViewById(R.id.tx_song_show);
            viewHolder.singShowTx.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mContext.startActivity(new Intent(mContext, RecordActivity.class));
                }
            });
            View viewDummy = convertView.findViewById(R.id.view_dummy);
            viewDummy.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mContext.startActivity(new Intent(mContext, UnisonListActivity.class));
                }
            });
            convertView.setTag(viewHolder);
            AutoUtils.autoSize(convertView);
        }
        return convertView;
    }

    private class ViewHolder {
        ImageView headImg;
        TextView songTitleTx;
        TextView shareUserTx;
        TextView sizeTx;
        TextView singerTx;
        TextView singShowTx;
    }

}
